package com.snjp.hywaytools;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import com.google.zxing.Result;
import com.zxing.CaptureFragment;

public class ScannerFragment extends CaptureFragment implements OnClickListener{
	
	public View contentView;
	
	public Button button;
	
	public TextView show;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		contentView = inflater.inflate(R.layout.bt_scan, null);
		return contentView;
	}
	
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		button = (Button)contentView.findViewById(R.id.scan);
		button.setOnClickListener(this);
		
		show = (TextView) contentView.findViewById(R.id.show);
	}

	@Override
	public void onClick(View v) {
		if(v == button){
			showDialogCapture();
		}
	}
	
	@Override
	public void handleDecode(Result obj, Bitmap barcode) {
		super.handleDecode(obj, barcode);
		show.setText(obj.toString());
	}
}
